package com.neusoft.my12306.controller;


import com.neusoft.my12306.common.res.CommonResult;
import com.neusoft.my12306.entity.Station;
import com.neusoft.my12306.service.IStationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 段静迪
 * @since 2023-07-06
 */
@RestController
@RequestMapping("/st")
@CrossOrigin
public class StationController {
    @Autowired
    IStationService stationService ;


    @GetMapping("/q/4auto/{v}")

    public CommonResult  find4Auto(@PathVariable String v ){
        return   stationService.find4Auto(    v );
    }

    @PostMapping("/mod")

    public CommonResult  modStation( @RequestBody  Station station){
        return  stationService.modStation(   station);
    }


    @GetMapping("/q/loadbycity/{city}")
/**
 * 根据城市的名字加载火车站信息
 */
    public CommonResult  loadByCity(@PathVariable String city){
        return   stationService.find4Auto(    city);
    }

    @PutMapping("/add")
    public CommonResult addStation(@RequestBody Station  station){
        return   stationService.addStation(  station);
    }

}
